/*
 * @Author: Sunye
 * @Date: 2025-03-31 15:38:17
 * @LastEditors: Sunye
 * @LastEditTime: 2025-03-31 15:56:15
 * @Description:
 */
import axios from 'axios';
const request = axios.create({
    baseURL: import.meta.env.BASE_URL,
    timeout: 5000,
});
//请求拦截器
request.interceptors.request.use((config) => {
    return config;
});
request.interceptors.response.use((response) => {
    return response.data;
}, (err) => {
    console.log(err);
    let msg = '';
    const status = err.response.status;
    switch (status) {
        case 401:
            msg = 'TOKEN过期';
            break;
        case 403:
            msg = '无权访问';
            break;
        case 404:
            msg = '请求地址错误';
            break;
        case 500:
            msg = '服务器错误';
            break;
        default:
            break;
    }
    console.log(msg);
    return Promise.reject(err);
});
export default request;
